import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import cesium from 'vite-plugin-cesium'
import path from 'path'

// https://vitejs.dev/config/
export default ({ mode }) => {
  // 参数mode为开发模式或生产模式
  const env = loadEnv(mode, process.cwd())
  const { VITE_APP_ENV, VITE_BASE_URL } = env
  return defineConfig({
    plugins: [vue(), cesium()],
    resolve: {
      alias: {
        '@': path.resolve(__dirname, 'src')
      }
    },
    // 项目打包配置
    base: VITE_BASE_URL,
    build: {
      outDir: 'dist',
      assetsDir: 'assets',
      sourcemap: false,
      terserOptions: {
        compress: {
          drop_console: true,
          drop_debugger: true,
        },
      },
    }
  })
}
